using System;
using System.Text;
using PPIDesktopClient.Logic;
using System.Collections.Generic;
using PPIDesktopClient.Entities.Kml;
using PPIDesktopClient.General;

namespace PPIDesktopClient.Entities
{
    [Serializable]
    public class EUtility_Asset_XMissionStructure : EBaseAsset
    {
        #region Miembros Privados
        protected List<EUtility_Asset_XMissionStructures_Pole> m_Poles;
        protected List<EUtility_Asset_XMissionStructures_Image> m_Images;

        EUtility m_Utility;
        EUtility_Contact m_Utility_Contact;
        EUtility_Project m_Project;
        #endregion Miembros Privados

        #region Propiedades
        public EUtility Utility
        {
            get { return m_Utility; }
            set { m_Utility = value; }
        }
        public EUtility_Contact Utility_Contact
        {
            get { return m_Utility_Contact; }
            set { m_Utility_Contact = value; }
        }

        public List<EUtility_Asset_XMissionStructures_Pole> Poles
        {
            get
            {
                return m_Poles;
            }
            set
            {
                m_Poles = value;
            }
        }
        public List<EUtility_Asset_XMissionStructures_Image> Images
        {
            get
            {
                return m_Images;
            }
            set
            {
                m_Images = value;
            }
        }

        public EUtility_Project Project
        {
            get
            {
                return m_Project;
            }
            set
            {
                m_Project = value;
            }
        }
        #endregion Propiedades

        #region Constructores
        #region summary
        /// <summary>
        /// Date: 04/28/2008
        /// Time: 11:47:12
        /// Generated by: VMCoder
        /// Generated using VirtualGenerator
        /// </summary>
        #endregion summary
        public EUtility_Asset_XMissionStructure()
            : base()
        {
            m_Project = new EUtility_Project();
            m_Poles = new List<EUtility_Asset_XMissionStructures_Pole>();
            m_Images = new List<EUtility_Asset_XMissionStructures_Image>();
            m_Utility = new EUtility();
            m_Utility_Contact = new EUtility_Contact();
        }
        public EUtility_Asset_XMissionStructure(Int32 id)
            : this()
        {
            m_id = id;
        }

        #endregion Constructores

        #region Override Methods

        public override void Delete()
        {
            LUtility_Asset_XMissionStructure.Delete(m_id);
        }

        protected override int Update()
        {
            new LUtility_Asset_XMissionStructure().Update(this);
            return m_id;
        }

        public override EBaseAsset GetServer()
        {
            return LUtility_Asset_XMissionStructure.GetUtility(Id);
        }

        public override string GetHtmlDescription()
        {
            StringBuilder _Shtml = new StringBuilder();
            _Shtml.AppendLine("<table style='font-family:Verdana; font-size:10px;' border='0'>");
            //Header
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td colspan=\"" + Poles.Count + 1 + "\"><b>XMission Structure | GPS Visit [" + Id + "]</b></td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td colspan=\"" + Poles.Count + 1 + "\" >");
            _Shtml.AppendLine("         <table>");
            _Shtml.AppendLine("             <tr>");
            _Shtml.AppendLine("                 <td>Utility : " + m_Utility.Name + "</td>");
            _Shtml.AppendLine("             </tr>");
            _Shtml.AppendLine("             <tr>");
            _Shtml.AppendLine("                 <td>Project : " + m_Project.Name + "</td>");
            _Shtml.AppendLine("             </tr>");
            _Shtml.AppendLine("             <tr>");
            _Shtml.AppendLine("                 <td>Contact : " + m_Utility_Contact.Name + "</td>");
            _Shtml.AppendLine("             </tr>");
            _Shtml.AppendLine("             <tr>");
            _Shtml.AppendLine("                 <td>Date : " + Date.ToString("m") + ", " + Date.ToString("yyyy") + " at " + Date.ToString("HH:mm tt") + "</td>");
            _Shtml.AppendLine("             </tr>");
            _Shtml.AppendLine("         </table>");
            _Shtml.AppendLine("     </td>");
            _Shtml.AppendLine(" </tr>");

            //Content
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>");
            _Shtml.AppendLine("         <table border='0'>");
            foreach (EBaseImage i in Images)
            {
                if (i.Pole.Id == Int32.MinValue)
                {
                    _Shtml.AppendLine("         <tr>");
                    _Shtml.AppendLine(i.GetHtml());
                    _Shtml.AppendLine("         </tr>");
                }
            }
            _Shtml.AppendLine("         </table>");
            _Shtml.AppendLine("     </td>");

            foreach (EBasePole p in Poles)
            {
                _Shtml.AppendLine("     <td>");
                _Shtml.AppendLine(p.GetHtmlDescription());
                _Shtml.AppendLine("     </td>");
            }
            _Shtml.AppendLine(" </tr>");
            string _webAdrress = Constants.K_GoogleMapDirectionsWEB;
            _webAdrress = _webAdrress.Replace("KML_DEST_ADDRESS", GetAddress());
            _webAdrress = _webAdrress.Replace("KML_SOURCE_ADDRESS", "100 Main Street Ovid, CO  80744".Replace(" ", "+"));
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td colspan=\"" + Poles.Count + 1 + "\">");
            _Shtml.AppendLine("         <table bolder='0'>");
            _Shtml.AppendLine("             <tr>");
            _Shtml.AppendLine("                 <td><a href=\"" + _webAdrress + "\">Get directions from Ovid office</a></td>");
            _Shtml.AppendLine("             </tr>");
            _webAdrress = Constants.K_GoogleMapDirectionsWEB;
            _webAdrress = _webAdrress.Replace("KML_DEST_ADDRESS", GetAddress());
            _webAdrress = _webAdrress.Replace("KML_SOURCE_ADDRESS", "16107 Hwy 14 Sterling, CO  80751".Replace(" ", "+"));
            _Shtml.AppendLine("             <tr>");
            _Shtml.AppendLine("                 <td><a href=\"" + _webAdrress + "\">Get directions from Sterling office</a></td>");
            _Shtml.AppendLine("             </tr>");
            _webAdrress = Constants.K_GoogleMapDirectionsWEB;
            _webAdrress = _webAdrress.Replace("KML_DEST_ADDRESS", GetAddress());
            _webAdrress = _webAdrress.Replace("KML_SOURCE_ADDRESS", "1300 S Interocean Holyoke, CO  80734".Replace(" ", "+"));
            _Shtml.AppendLine("             <tr>");
            _Shtml.AppendLine("                 <td><a href=\"" + _webAdrress + "\">Get directions from Holyoke office</a></td>");
            _Shtml.AppendLine("             </tr>");
            _Shtml.AppendLine("         </table>");
            _Shtml.AppendLine("     </td>");
            _Shtml.AppendLine("</table>");
            return _Shtml.ToString();
        }

        protected override string GetHtmlName()
        {
            string _Name = "";
            EUtility_QueryAssetTextShow title = GetTextToShow();
            switch (title)
            {
                case EUtility_QueryAssetTextShow.Internal_Utility_ID:
                    _Name = "Utility [ " + m_id.ToString() + " ]";
                    break;
                case EUtility_QueryAssetTextShow.AID:
                    _Name = "Utility [  ]";
                    break;
                case EUtility_QueryAssetTextShow.Top_Type:
                    _Name = "Utility [ " + TopType.Name + " ]";
                    break;
                default:
                    break;
            }
            return _Name;
        }

        protected override string GetPlacemarkId()
        {
            return "Utility_" + Id.ToString();
        }

        #endregion

    }
}

